import time

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from Base import Base
class Page(Base):
    dz='https://login.jiuxian.com/login.htm'
    zh=(By.NAME,'uname')
    mm=(By.ID,'password')
    dl=(By.XPATH,'//*[@id="save"]')
    qd=(By.CLASS_NAME,'bindSub')
    srk=(By.XPATH,'/html/body/div[3]/div/div[2]/div[1]/form/input[1]')
    sp=(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')
    jr=(By.XPATH,'//*[@id="addToCartForDetail"]')
    jrgw=(By.XPATH,'//*[@id="u-buy-layId"]/div/div[3]/a[2]')
    js=(By.XPATH,'//*[@id="cart_container"]/div[3]/div[3]/a[1]')
    wc=(By.XPATH,'//*[@id="submitOrder"]')
    def cz(self,username,password):
        self.get_url(self.dz)
        time.sleep(2)
        self.send_keys(self.zh,username)
        time.sleep(2)
        self.send_keys(self.mm,password)
        time.sleep(20)
        self.click(self.dl)
        time.sleep(2)
        self.click(self.qd)
        time.sleep(2)
        self.send_keys(self.srk,'剑南春')
        time.sleep(2)
        self.send_keys(self.srk,Keys.ENTER)
        time.sleep(2)
        self.click(self.sp)
        time.sleep(2)
        self.yem()
        self.click(self.jr)
        time.sleep(2)
        self.click(self.jrgw)
        time.sleep(2)
        self.click(self.js)
        time.sleep(2)
        self.click(self.wc)
